import requests
class DepaManage(object):
    def add_depa(self,head_data,depa_data):  #添加
        resp=requests.post(url="http://ihrm2-test.itheima.net/api/company/department",
                           headers=head_data,json=depa_data)
        return resp
    def modify_depa(self,depa_id,head_data,query_data):  #修改
        resp=requests.put(url="http://ihrm2-test.itheima.net/api/company/department/"+depa_id,
                           headers=head_data,json=query_data)
        return resp
    def query_depa(self,depa_id,head_data):         #查询
        resp=requests.get(url="http://ihrm2-test.itheima.net/api/company/department/"+depa_id,
                           headers=head_data)
        return resp
    def delete_depa(self,depa_id,head_data):        #删除
        resp=requests.delete(url="http://ihrm2-test.itheima.net/api/company/department/"+depa_id,
                           headers=head_data)
        return resp
if __name__ == '__main__':
    depa=DepaManage()
    head_data = {"Authorization": "0277db8c-b217-4254-8daa-812ad7d4b768"}
    depa_id = "1570777919301742592"
    resp1=depa.query_depa(depa_id,head_data)
    print("查询",resp1.json())

    depa_data={"name":"德玛西亚","code":"9527"}
    resp2=depa.add_depa(head_data,depa_data)
    print("查询",resp2.json())

    depa2_id="1570777919301742592"
    query_data={"name":"德玛88","code":"9566666"}
    resp3=depa.modify_depa(depa2_id,head_data,query_data)
    print("修改",resp3.json())

    depa3_id="1570783648544845824"
    resp4 = depa.delete_depa(depa3_id,head_data)
    print("删除",resp4.json())


